home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
develop, the CD; issue 1
/
Apple_Develop_1989.bin
/
Realistic Color
/
RW Bulls Eye
/
RW Bullseye.c
< prev
next >
Wrap
C/C++ Source or Header
|
1989-11-16
|
3KB
|
158 lines
/*
* file: RW Bullseye.c
*
* started 7 August 1988 23:06
* david van brink
*
* A Sample of NewGWorld in action.
*
************************************
* Inclusions
************************************/
#include "colortoolbox.h"
#include "EventMgr.h"
#include "MenuMgr.h"
#include "BigEasy2.h"
#include "QuickDraw32Bit.h"
/************************************
* Types and globals
************************************/
extern Rect gBigRect;
GWorldPtr gMyOffG;
Rect dOffBounds = {0,0,256,256};
DrawSplug()
/*
* Draws the window.
*/
{
Rect r;
EraseRect(&gBigRect);
ForeColor(blackColor);
CopyBits(&gMyOffG->portPixMap,&thePort->portBits,&dOffBounds,&dOffBounds,ditherCopy,0);/**/
}
int ClickSplug(n,p)
/*
* Come here for a click in the window.
*/
short n; /* window number */
Point p; /* where clicked */
{
}
GoAwaySplug(n)
/*
* Close that window...
*/
short n;
{
UninstallWindow(n);
}
int ActivateSplug(n)
{
SetMenuItem(23,true,0,0,nil); /* enable "Close" menu item */
SetMenuItem(24,false,0,0,nil); /* disable "Open" menu item */
KillEds();
}
int DeactivateSplug(n)
{
SetMenuItem(23,false,0,0,nil); /* disable "Close" menu item */
SetMenuItem(24,true,0,0,nil); /* enable "Open" menu item */
}
int pnull(){}
letsquit(){gQuitApp++;}
KillEds()
{
EnDisEdits(0,0,0,0,0);
}
OpenWindow()
{
Rect r;
SetRect(&r,100,100,100+dOffBounds.right,100+dOffBounds.bottom);
InstallWindow(1,"\pWindow",&r,0,1,
(FP)DrawSplug,ClickSplug,pnull,GoAwaySplug,
DeactivateSplug,ActivateSplug,pnull);
}
InitVars()
/*
* Called once at startup: yes, it
* inits the vars.
*/
{
GDHandle oldGD;
GWorldPtr oldGW;
HSVColor hsvc;
RGBColor rgbc;
long x;
Rect r;
short QDErr;
GetGWorld(&oldGW,&oldGD);
QDErr = NewGWorld(&gMyOffG,32,&dOffBounds,nil,nil,0);
if (QDErr) /* exit_to_shell */ ;
LockPixels(gMyOffG->portPixMap);
SetGWorld(gMyOffG,nil);
for(x = 0; x<dOffBounds.right; x++)
{
rgbc.red = rgbc.green = rgbc.blue = x * 65535 / (dOffBounds.right - 1);
RGBForeColor(&rgbc);
MoveTo(x,0);
LineTo(x,dOffBounds.bottom);
}
r = dOffBounds;
hsvc.value = 65535;
hsvc.saturation = 65535;
for (x = dOffBounds.right/2; x; x--)
{
hsvc.hue = x * 131070/(dOffBounds.right - 1);
HSV2RGB(&hsvc,&rgbc);
RGBForeColor(&rgbc);
FrameOval(&r);
InsetRect(&r,1,1);
}
SetGWorld(oldGW,oldGD);
}
Bootstrap()
{
InitVars();
/*** Menu 2 ***/
InstallMenu("\pFile",pnull,0);
InstallItem("\pOpen/O",OpenWindow,23);
InstallItem("\pClose/W",GoAwaySplug,-24);
InstallItem("\p(-",pnull,0);
InstallItem("\pQuit/Q",letsquit,0);
/*** Menu 3 ***/
InstallEditMenu(pnull,pnull,pnull,pnull,pnull);
KillEds();
OpenWindow();
}